package AST;

import java.util.ArrayList;
import java.util.Iterator;
import java.util.List;

import Lexer.Symbol;

public class Term {
	private List<Factor> factorList = new ArrayList<Factor>();
	private List<Integer> opList = new ArrayList<Integer>();

	public Term(List<Factor> factorList, List<Integer> opList) {
		print();
		this.factorList = factorList;
		this.opList = opList;
	}

	public Term() {
		print();
	}

	public List<Factor> getFactorList() {
		return factorList;
	}

	public void setFactorList(List<Factor> factorList) {
		this.factorList = factorList;
	}

	public List<Integer> getOpList() {
		return opList;
	}

	public void setOpList(List<Integer> opList) {
		this.opList = opList;
	}

	public void addOpList(int op) {
		this.opList.add(op);
	}

	public void addFactorList(Factor fac) {

		this.factorList.add(fac);
	}

	public void print() {
		System.out.println("Term");
	}

	public void genC(PW pw) {
		Iterator<Factor> itFactor = factorList.iterator();

		itFactor.next().genC(pw);
		for (int op : opList) {
			if (op == Symbol.MULT)
				pw.print("*");
			if (op == Symbol.DIV)
				pw.print("/");
			if (op == Symbol.MOD)
				pw.print("%");
			/*
			 * if (op == Symbol.FLOORDIV) pw.print("/"); em C floor div fica
			 * floor(a/b) n�o sei fazer isso aqui ainda
			 */
			itFactor.next().genC(pw);
		}

	}

}
